package com.itheima.edu.info.manager.day16;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class ClassTest2 {
    public static void main(String[] args) throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException {
      //  Declaredconstructor();

     //   constructor();
    }

    private static void constructor() throws NoSuchMethodException {
        Class c=Student.class;
        Constructor constructor = c.getConstructor();
        System.out.println(constructor);
    }

    private static void Declaredconstructor() throws ClassNotFoundException, NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
        Class aClass = Class.forName("com.itheima.edu.info.manager.day16.Student");
        Constructor constructor = aClass.getDeclaredConstructor(String.class);
        constructor.setAccessible(true);
        Student o = (Student) constructor.newInstance("老杨");
        System.out.println(o);
    }
}
